package com.example.zhihuhelpapp.configs;

import android.view.View;
import android.widget.TextView;

import com.example.zhihuhelpapp.R;
import com.example.zhihuhelpapp.base.BaseActivity;
import com.example.zhihuhelpapp.utils.CoreConstant;
import com.example.zhihuhelpapp.utils.SpUtils;
import com.example.zhihuhelpapp.utils.UIUtils;

public class ConfigInfoActivity extends BaseActivity implements View.OnClickListener {
    private TextView mTvJdAppKey;
    private TextView mTvJdAppSecret;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_config_info;
    }

    @Override
    protected void initView() {
        showToolBar(true, getString(R.string.app_config_info));

        mTvJdAppKey = findViewById(R.id.mTvJdAppKey);
        mTvJdAppSecret = findViewById(R.id.mTvJdAppSecret);

        String jdAppKey = SpUtils.getInstance().get(CoreConstant.SpConstant.KEY_JD_APP_KEY, "");
        String jdAppSecret = SpUtils.getInstance().get(CoreConstant.SpConstant.KEY_JD_APP_SECRET, "");

        mTvJdAppKey.setText("京东AppKey：" + jdAppKey);
        mTvJdAppSecret.setText("京东AppSecret：" + jdAppSecret);

        mTvJdAppKey.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.mTvJdAppKey:
                String value = mTvJdAppKey.getText().toString().trim().split("：")[1];
                UIUtils.copy(this,value);
                UIUtils.showToast("已复制");
                break;
            case R.id.mTvJdAppSecret:
                value = mTvJdAppSecret.getText().toString().trim().split("：")[1];
                UIUtils.copy(this,value);
                UIUtils.showToast("已复制");
                break;
        }
    }
}
